<?php

namespace App\Http\Controllers\Admin;

use App\Http\Controllers\Controller;
use App\Repositories\UserLogRepository;
use App\Http\Requests\Admin\UserLog\QueryResource;

class LogController extends Controller
{
    protected $userLogRepository;

    /**
     * UserLogsController constructor.
     * @param UserLogRepository $userLogRepository
     */
    public function __construct(
        UserLogRepository $userLogRepository
    )
    {
        $this->userLogRepository = $userLogRepository;
    }

    /**
     * 获取日志列表
     *
     * Date: 2018/4/10
     * @author Tenny
     * @param QueryResource $request
     * @return \Illuminate\Http\JsonResponse
     */
    public function index(QueryResource $request)
    {
        $limit = $request->get('paginate', 15);
        $uid = $request->get('uid', false);
        $type = $request->get('type', false);
        $service_id = $request->get('service_id', false);
        $order_id = $request->get('order_id', false);
        $userLogs = $this->userLogRepository->getLog($uid, $service_id, $type, $order_id, $limit);
        return success($userLogs);
    }
}
